package com.aaa.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import java.util.ArrayList;

import static springfox.documentation.builders.PathSelectors.regex;

/**
 * @program: aaa-hospital-parent
 * @description:
 * @author: 闫克起
 * @create: 2024-05-20 16:07
 **/
@Configuration //该类为配置类
public class SwaggerConfig {
    @Bean
    public Docket docket(){
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                .groupName("qy173")//设置组名
                .apiInfo(apiInfo()) //文档信息介绍
                .select()
                .paths(regex("^.*(?<!error)$"))
                //.apis(RequestHandlerSelectors.basePackage("com.aaa.controller"))//为哪个bao生成接口文档
                .build()
                ;
        return docket;
    }

    private ApiInfo apiInfo(){
        Contact DEFAULT_CONTACT = new Contact("李文帅", "http://www.jd.com", "110@qq.com");
        ApiInfo info = new ApiInfo("测试swagger文档", "测试swagger文档", "2.0", "http://www.baidu.com",
                DEFAULT_CONTACT, "AAA集团", "http://www.aaa.comm", new ArrayList<VendorExtension>());
        return info;
    }
}
